<%@page contentType="text/xml; charset=utf-8" pageEncoding="utf-8" %>
<%
	request.setCharacterEncoding("UTF-8");
	String query = request.getParameter("query");
	String name = request.getParameter("name");
	String sort = request.getParameter("sort");
	
	//String query = new String(request.getParameter("query").getBytes("8859_1"),"UTF-8");
	 
	String urlPath = "";
	String charset = "utf-8";
	
	if (query == null) {
		query = "ipodtouch";
	}
	if (name.equals("naver")){
		if (sort.equals("new"))
			sort = "date";
		if (sort.equals("high"))
			sort = "dsc";
		if (sort.equals("low"))
			sort = "asc";
		urlPath = "http://openapi.naver.com/search?key=e74f4e476ae4695a5098fe088812a820&query="
			+query+"&display=5&start=1&target=shop&sort="+sort;
	}
	else if (name.equals("daum")){
		if (sort.equals("new"))
			sort = "date";
		if (sort.equals("high"))
			sort = "max_price";
		if (sort.equals("low"))
			sort = "min_price";
		urlPath = "http://apis.daum.net/shopping/search?apikey=122f79602e33855936ce0741dedab5ad218eda9b&q="+query+"&display=5&sort="+sort;
	}
	else if (name.equals("eleven")){
		urlPath = "http://openapi.11st.co.kr/openapi/OpenApiService.tmall?key=bd091020b99c89b9ad05a29a9e83e555&apiCode=ProductSearch&keyword="+query+"&pageSize=5";
		charset = "EUC-KR";
		response.setHeader("Content-Type", "text/xml; charset=euc-kr");
	}
	
	String xml = kr.pe.okjsp.rss.RSSProxy.getXML(urlPath, charset);
%><%= xml %>
